package lanQiaoBei.violent_recursion;
/*
* 将一串数字转化为字母在合法的情况下可以任意转化
* 1112 aaab aal akb kab kl
* */
public class TransferNum {
    public static void main(String[] args) {
           realize("1112");
    }
    public static void realize(String str){
        char[] chars = str.toCharArray();
        System.out.println(f(chars, 0));
    }

    private static int f(char[] chars, int i) {
            if(i==chars.length){
                return 1;
            }
            if(chars[i]=='0')return 0;
            //如果chars[i]==‘1’
           int res=0;
           if(chars[i]=='1'){
               res+=f(chars,i+1);
               if(i+1<chars.length){
                   res+=f(chars,i+2);
               }
               return res;
           }
           if(chars[i]=='2'){
               res+=f(chars,i+1);
               if(i+1<chars.length&&chars[i+1]>'0'&&chars[i+1]<='6'){
                   res+=f(chars,i+2);
               }
               return res;
           }
           return f(chars,i+1);
    }
}
